<?php
 /*
  *总后台商品模型类
  */
namespace Home\Model; 
use Think\Model;
class ItemModel extends Model{
	public function index()
	{
		$result=array();
		if(empty($_SESSION['supperid']))
		{
			return '';
		}
		$where['supperid']=$_SESSION['supperid'];
		
		$page=I('get.page','1','strip_tags');
        $count=M('item')->where($where)->count();
        $result['pagearr']= getPageArr($page,C('PAGESIZE'),$count);
        
		$result['item']=M('item')->where($where)
						 ->order('itemid desc')
		                 ->limit($result['pagearr']['start'],$result['pagearr']['pagesize'])
		                 ->select();
		//判读此商品是否存在多规格
		if(!empty($result))
		{	$product=M('product');
			foreach ($result['item'] as $key =>&$value) {
				$temp=$product->where('itemid=%d',$value['itemid'])->count();
				$value['isspeci']=!empty($temp)?1:0; //是否多规格
			}

		}
		

		return $result;
	}
}